﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.Entities;
using ueEngine.Biz.Inf.LogicEntity.SupportData;
using ueEngine.Biz.Inf.Entities.DBSupport;

namespace ueEngine.Biz.Inf.LogicEntity
{
    public class DepositCompanyModel:IAccessible<DepositCompany,DepositCompanyModel>
    {
        #region self
        public int Id { get; set; }
        /// <summary>
        /// 所属代理人
        /// </summary>
        public string Agent { get; set; }
        /// <summary>
        /// 公司名称
        /// </summary>
        public string CompanyName { get; set; }
        /// <summary>
        /// (如果是新添加公司)公司描述
        /// </summary>
        public string CompanyDetail { get; set; }
        /// <summary>
        /// 行业分类
        /// </summary>
        public Business CompanyBusiness { get; set; }
        /// <summary>
        /// 企业类型
        /// </summary>
        public CompanyType CompanyType { get; set; }
        /// <summary>
        /// 企业规模
        /// </summary>
        public CompanyDimensions CompanyDimensions { get; set; }
        /// <summary>
        /// 添加日期
        /// </summary>
        public DateTime PostDate { get; set; }
        /// <summary>
        /// 以此创建模板
        /// </summary>
        public bool Templete { get; set; }
        #endregion

        protected override void Covariant(DepositCompany dbModel)
        {
            this.Agent = dbModel.Agent;
            this.CompanyDetail = dbModel.CompanyDetail;
            this.CompanyName = dbModel.CompanyName;
            this.Id = dbModel.Id;
            this.PostDate = dbModel.PostDate;
            this.Templete = dbModel.Templete;
            this.CompanyBusiness = (Business)dbModel.CompanyBusiness;
            this.CompanyType = (CompanyType)dbModel.CompanyType;
            this.CompanyDimensions = (CompanyDimensions)dbModel.CompanyDimensions;
        }
        protected override DepositCompany Inverter(DepositCompanyModel model)
        {
            return new DepositCompany()
            {
                Agent = model.Agent,
                CompanyDetail = model.CompanyDetail,
                CompanyName = model.CompanyName,
                Id = model.Id,
                PostDate = model.PostDate,
                Templete = model.Templete,
                CompanyBusiness = (int)model.CompanyBusiness,
                CompanyDimensions = (int)model.CompanyDimensions,
                CompanyType = (int)model.CompanyType
            };
        }
        //public override DepositCompanyModel Element(System.Linq.Expressions.Expression<Func<DepositCompany, bool>> where)
        //{
        //    Covariant(new DepositCompany().Get(where));
        //    return this;
        //}

        //public override List<TResult> Elements<TResult>(System.Linq.Expressions.Expression<Func<DepositCompany, bool>> where, System.Linq.Expressions.Expression<Func<DepositCompany, TResult>> select)
        //{
        //    using (Context ctx = new Context())
        //    {
        //        return ctx.DepositCompany.Where(where).Select(select).ToList();
        //    }
        //}
    }
}
